function [States,pproc_boot] = GenStateVariablesBoot(DS,opt,AgeState,pproc)

%% Create SugBufState variable
SugRoadDist = double(DS(:,16:25));
SugRoadDist = [nan(size(DS,1),2) SugRoadDist(:,1:end-1)/1000]; % Work with distance in km!
% Prepare classification of sugarcane road distance:
MaxSugRoadDist = max(max(SugRoadDist));
SugRoadDistClasses = [opt.SRDthresholds'; MaxSugRoadDist];
SugRoadDistClasses = repmat(SugRoadDistClasses, [1 size(SugRoadDist,2)]);
[States.SRDStates,States.SRDMidPoints] = ClassStates(SugRoadDist,SugRoadDistClasses);
States.SRDStates(States.SRDStates==0) = NaN;

% This function only runs this other three functions, one for each type of
% exogenous state variable and a final one aggregates all state variables

% Generate exogenous time varying state variables (based on ):
[States.ExoTimeStates,States.RegionsForExoStates,pproc_boot] = GenExoTimeStatesBoot(DS,opt,pproc);

% Generate exogenous fixed state indices:
[States.ExoFixedStates,States.MidPointsFixedStates] = GenExoFixedStates(DS,opt);

% Create single state index:
[States.FixedStatesMap,States.AllStatesMap,States.SingleStateIdx] = StatesMapping(States.ExoFixedStates,States.ExoTimeStates,AgeState,States.SRDStates,opt);


States.SRDStates      = uint8(States.SRDStates);
States.AllStatesMap   = uint16(States.AllStatesMap);
States.SingleStateIdx = uint32(States.SingleStateIdx);
States.FixedStatesMap = uint16(States.FixedStatesMap);

end